= Jenkinsfile Runner Architecture overview
:toc:
:toc-placement: preamble
:toclevels: 3

This page provides a brief overview of the Jenkinsfile Runner architecture.

== Modules

There are 6 modules:

* `app`
* `bootstrap`
* `payload`
* `payload-dependencies`
* `setup`
* `tests`

The `demo` folder contains some examples, especially demonstrating the
integration with https://github.com/jenkinsci/custom-war-packager/[Custom WAR Packer].

== `app` module

Picks what's necessary from other modules by adding them as dependencies and configures
the `appassembler-maven-plugin` so that an assembly is generated, containing the Jenkinsfile Runner as an
executable script.

== `bootstrap` module

Contains special classloader configuration so that Jenkinsfile Runner is able to work both with Jenkins classes and with the
own project classes. It also contains the `Bootstrap` class:

* The `main()` for the Jenkinsfile Runner application.
* Contains Jenkinsfile Runner Command options and implementations.
* Configures the execution based on the values of the provided parameters.
* Launches the execution and prepares the environment.
  In particular, the module prepares the Jenkins WAR and plugins when it is needed.

== `payload` module

Contains the configuration for the "real" pipeline job to be configured and run on the ephemeral Jenkins instance. It basically:

* Creates a Pipeline job configured to optimize performance.
* Sets the Jenkinsfile to be executed.
* Sets the specified parameters.
* (Un)Sets the script security plugin security layer.
* Schedules a build and wait for the finalization, redirecting the logs to the system output.

== `payload-dependencies` module

The `payload` module depends on the presence of many other plugins,
but they are only used during the compilation and therefore are not shipped to runtime.

Having all the dependencies under payload-dependencies makes it easier to exclude
them from the assembly.

== `setup` module

It implements the `JenkinsfileRunnerLauncher` in charge of starting the Jenkins instance and calling the Jenkinsfile Runner
execution engine, configuring the classloader properly.

It also contains classes to implement or configure this "environment", such as a custom implementation for the Plugin Manager
or a WAR exploder in charge of exploding the WAR file and fully initializing an instance.

== `vanilla-package` module

Defines the dependencies to be included in the Vanilla Docker distribution.
It also includes unit tests that verify basic functionality of Jenkinsfile Runner.

== `tests` module

Contains the integration tests powered by the https://github.com/jenkinsci/jenkinsfile-runner-test-framework[Jenkinsfile Runner Test Framework].
